<%@page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.sql.*"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Trang sản phẩm</title>
        <link href="css/index_style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="baby_wrapper_outter">

            <div id="baby_wrapper_inner">
                <%@include file="top.jsp"%>
                <div id="baby_content_wrapper">
                    
                    <div id="baby_left_sidebar_wrapper">

                        <%@include file="left.jsp"%>

                    </div> 
                    <div id="baby_right_sidebar_wrapper">

                        <%@include file="right.jsp"%>

                    </div> 

                    <div id="baby_content">
                           Sản phẩm :
                        <div class="content_section">
                            <c:if test="${requestScope.listqa==null}">   <%-- nếu dánh sp rỗng 
                                                                              gọi serverlet GetAll để lấy       --%>
                                <c:redirect url="GetAll?page=1"/>
                            </c:if>
                            
                            <c:if test="${requestScope.listd==null}">
                                <c:redirect url="GetAll?page=1"/>
                            </c:if>
                                                                               
                            <div class="content_section1">
                               <%-- đưa ra danh sách sản phẩm
                                           --%>
                                <table>
                                    <c:forEach items="${requestScope.listqa}" var="qa">      
                                     <%-- truy suất vào bộ nhớ trình duyệt để lấy danh sách
                                           --%>   
                                      <tr>                                          
                                          <td width="200" height="180" class="table">
                                            <img src= ${qa.image} width="200" height="150"/> 
                                            <a href="Show?id=${qa.id}" style=" color: #660033"> ${qa.name} </a>  
                                            <%-- lấy id và chuyển sang trang show để đưa ra chi tiết sp
                                           --%>
                                          </td>
                                      </tr>
                                    </c:forEach>
                                </table>
                            </div>
                            <div class="content_section2">
                            <table>
                                <c:forEach items="${requestScope.listd}" var="d">                                       
                                      <tr>                                          
                                          <td width="200" height="180" class="table">
                                          <img src= ${d.image} width="200" height="150"/> 
                                            <a href="Show?id=${d.id}" style=" color: #660033"> ${d.name} </a>                                           
                                        </td>
                                      </tr>
                                </c:forEach>
                            </table>                            
                            </div>
                            
                            <a href="GetAll?page=1">    <input type="submit" name="btpage" value="1" > </a>
                            <a href="GetAll?page=2">    <input type="submit" name="btpage" value="2" > </a>
                                                       
                        </div>                    
                    </div>

                    <div class="cleaner"></div>

                </div> <!-- end of baby_content_wrapper -->

            </div> <!-- end of baby_wrapper_inner -->
        </div> <!-- end of baby_wrapper_outter -->
        <%@include file="bottom.jsp"%>
    </body>
</html>